﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.Responsibility
{
    class Program
    {
        static void Main(string[] args)
        {
            //请假申请
            ApplyContext applyContext = new ApplyContext()
            {
                Id = 1,
                Name = "张三",
                Hour = 32
            };

            #region 代码翻译机
            //{
            //    AbstractManager projectManager = new ProjectManager();
            //    projectManager.Approval(applyContext);
            //    if (!applyContext.ApprovalResult)
            //    {
            //        AbstractManager departmentManager = new DepartmentManager();
            //        departmentManager.Approval(applyContext);
            //        if (!applyContext.ApprovalResult)
            //        {
            //            AbstractManager companyManager = new CompanyManager();
            //            companyManager.Approval(applyContext);
            //        }
            //    }
            //}
            #endregion

            #region 高级开发
            //{
            //    AbstractManager projectManager = new ProjectManager();
            //    projectManager.Approval(applyContext);
            //}
            #endregion

            #region 架构
            {
                AbstractManager projectManager = new ProjectManager();
                projectManager.Name = "项目经理王";

                AbstractManager departmentManager = new DepartmentManager();
                departmentManager.Name = "部门经理李";

                AbstractManager companyManager = new CompanyManager();
                companyManager.Name = "公司老总张";

                //项目经理设置下一个审批人是部门经理
                projectManager.SetNext(departmentManager);
                //部门经理设置下一个审批人是公司经理
                departmentManager.SetNext(companyManager);

                //项目经理开始审批
                projectManager.Approval(applyContext);
            }
            #endregion
        }
    }
}
